def take_second(elem):
    return elem[1]


def load_value(in_degree, out_degree):
    return in_degree + out_degree


def load_name_of_node(node):
    if node['MMSI'] is not None:
        return node['MMSI']
    elif node['port_name'] is not None:
        return node['port_name']
    elif node['country_name'] is not None:
        return node['country_name']
    elif node['ship_owner_name'] is not None:
        return node['ship_owner_name']
    else:
        raise Exception('没有找到name')


def load_type_of_link(relation):
    relation_ship_mapping_dict_2_chinese = {
        "Accompany": "伴随",
        "belong_to": "船旗国为",
        "ARRIVE": "到达",
        "JOURNEY_TO": "JOURNEY_TO",
        "LEAVE": "离开",
        "own": "拥有"
    }
    relation_ship_mapping_dict_2_default = {
        "Accompany": "Accompany",
        "belong_to": "belong_to",
        "ARRIVE": "ARRIVE",
        "JOURNEY_TO": "JOURNEY_TO",
        "LEAVE": "LEAVE",
        "own": "own"
    }
    relation_ship_mapping_dict = relation_ship_mapping_dict_2_default
    query_key = str(type(relation).__name__)
    return relation_ship_mapping_dict[query_key]

    # if 'Accompany' in str(type(relation)):
    #     return relation_ship_mapping_dict['Accompany']
    # elif 'belong_to' in str(type(relation)):
    #     return relation_ship_mapping_dict['belong_to']
    # elif 'ARRIVE' in str(type(relation)):
    #     return relation_ship_mapping_dict['ARRIVE']
    # elif 'JOURNEY_TO' in str(type(relation)):
    #     return relation_ship_mapping_dict['JOURNEY_TO']
    # elif 'LEAVE' in str(type(relation)):
    #     return relation_ship_mapping_dict['LEAVE']
    # elif 'own' in str(type(relation)):
    #     return relation_ship_mapping_dict['own']
    # else:
    #     raise Exception('没有找到关系类型')
